package com.wen.qqrobot;

import com.wen.qqrobot.util.ArrayUtil;
import com.wen.qqrobot.util.BrowserLauncher;
import com.wen.qqrobot.util.ObjectUtil;

import javax.swing.*;

/**
 * Created by wenwen on 2016/10/5.
 * version 1.0
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //showVersionMessage(args);
        //获取配置
        Config config = Config.getInstance();
        //输出配置信息
        System.out.println(ObjectUtil.getObjectInfo(config));
        //初始化QQ服务器
        QQServer qq = new QQServer();
        //设置黑名单
        qq.setBlacklist(new Blacklist(config.getBlacklist()));
        //设置群过滤器
        qq.setGroupFilter(new GroupFilter(config.getGroups()));
        //登录
        qq.login();
    }

    private static void showVersionMessage(String[] args) {
        if (ArrayUtil.isEmpty(args) || args.length < 2
                || !args[args.length - 2].equals("2.8")) {
            JOptionPane.showMessageDialog(null,
                    "最新版启动器修改了严重Bug，请尽快从打开的页面里下载最新版！",
                    "版本警告", JOptionPane.WARNING_MESSAGE
            );
            BrowserLauncher.openURL("http://pan.baidu.com/s/1sj4hKvV");
            System.exit(1);
        }
    }

}
